package com.xiaocz.common.utils;
import android.util.Log;

import com.xiaocz.common.Common;

/**
 * Debug 测试跟踪打印类对象
 *
 * @author
 *
 */
public class Debug {

	/** 起始执行时间. */
	public static long startLogTimeInMillis = 0;
	/**
	 * debug输出的默认标签名称
	 */
	public static String TAG = "LOG";
	/**
	 * 错误日志记录文件
	 */
	private static final String logName="error.log";
	private static final String debugLogName="debug.log";

	public static void debug(String paramString) {
		if (Common.Constant.testing){
			Log.d(TAG, paramString);
		}
	}

	public static void debug(String tag, String paramString) {
		if (Common.Constant.testing){
			Log.d(tag, paramString);
//			WriteLog.printString(tag+"\n"+paramString,debugLogName);
		}
	}

	public static void error(String paramString) {
		if (Common.Constant.testing){
			Log.e(TAG, paramString);
		}
	}

	public static void error(Exception e) {
		if (Common.Constant.testing) {
			e.printStackTrace();
			StringBuffer sb=new StringBuffer();
			sb.append(e.getMessage());
			for (StackTraceElement ement : e.getStackTrace()) {
				sb.append("\n");
				sb.append(ement.toString());
			}
		}
	}

	public static void error(String tag, String paramString) {
		if (Common.Constant.testing) {
			Log.e(tag, paramString);
		}
	}

	public static void error(String tag, Exception e) {
		if (Common.Constant.testing) {
			e.printStackTrace();
			StringBuffer sb=new StringBuffer();
			sb.append(tag);
			sb.append(e.getMessage());
			for (StackTraceElement ement : e.getStackTrace()) {
				sb.append("\n");
				sb.append(ement.toString());
			}
		}
	}

	public static void info(String paramString) {
		if (Common.Constant.testing)
			Log.i(TAG, paramString);
	}

	public static void info(String tag, String paramString) {
		if (Common.Constant.testing)
			Log.i(tag, paramString);
	}

	public static void trace(String paramString) {
		if (Common.Constant.testing) {
			Log.v(TAG, paramString);
		}
	}

	public static void trace(String paramString1, String paramString2) {
		if (Common.Constant.testing)
			Log.v(paramString1, paramString2);
	}

	public static void warn(String paramString) {
		if (Common.Constant.testing) {
			String str = "Warning: " + paramString;
			Log.w(TAG, str);
		}
	}

	public static void warn(String paramString1, String paramString2) {
		if (Common.Constant.testing) {
			String str = "Warning: " + paramString2;
			Log.w(paramString1, str);
		}
	}
}
